package cn.stylefeng.guns.modular.basic.controller;

import cn.stylefeng.guns.modular.basic.model.params.CommonParam;
import cn.stylefeng.guns.modular.basic.service.ArchiveDictService;
import cn.stylefeng.guns.modular.basic.service.CommonService;
import cn.stylefeng.guns.modular.basic.service.utils.TreeKit;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/archiveDic")
public class ArchiveDictController extends BaseController {

    @Autowired private ArchiveDictService archiveDictService;

    @Autowired private CommonService commonService;

    @RequestMapping("/commonTree")
    @ResponseBody
    public ResponseData commonTree(CommonParam param) {
        return ResponseData.success(this.commonService.commonTree(param));
    }

    @RequestMapping("/listTypeDict")
    @ResponseBody
    public ResponseData listTypeDict() {
        return ResponseData.success(this.archiveDictService.listTypeDict());
    }

    @RequestMapping("/archiveRoom")
    @ResponseBody
    public ResponseData archiveRoomList() {

        return ResponseData.success(TreeKit.combine(this.archiveDictService.listArchiveRoom()));
    }


    @RequestMapping("/archiveCabinet")
    @ResponseBody
    public ResponseData archiveCabinetList() {
        return ResponseData.success(TreeKit.combine(this.archiveDictService.listArchiveRoom(),this.archiveDictService.listArchiveCabinet()));
    }

    @RequestMapping("/archiveLayer")
    @ResponseBody
    public ResponseData archiveLayerList() {
        return ResponseData.success(TreeKit.combine(this.archiveDictService.listArchiveRoom(),this.archiveDictService.listArchiveCabinet(),this.archiveDictService.listArchiveLayer()));
    }

    @RequestMapping("/archiveBox")
    @ResponseBody
    public ResponseData archiveBoxList() {
        return ResponseData.success(TreeKit.combine(this.archiveDictService.listArchiveRoom(),this.archiveDictService.listArchiveCabinet(),this.archiveDictService.listArchiveLayer(),this.archiveDictService.listArchiveBox()));
    }

}
